package vue;

import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

import controleur.CActionCard;

import modele.MCard;

public class VCard extends JPanel {
	
	/*
	 * GUI d'une carte
	 */
	
	//Lien vers le modele
	protected MCard cardModel;
	
	public VCard(MCard c) {
		cardModel = c;
		setPreferredSize(new Dimension(cardModel.getBack().getWidth(), cardModel.getBack().getHeight()));
		
		addMouseListener(new CActionCard(this, cardModel));
	}
	
	@Override
	public void paintComponent(Graphics g) {
		System.out.print("ok");
		if(cardModel.isVisible())
			drawFront(g);
		else
			drawBack(g);
	}
	
	public void drawFront(Graphics g) {
		g.drawImage(cardModel.getFront(), 0, 0, null);
	}
	
	public void drawBack(Graphics g) {
		g.drawImage(cardModel.getBack(), 0, 0, null);
	}

}
